Skip to content

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Jan 3, 2025

error[E0106]: missing lifetime specifier
  --> $DIR/bad-lifetimes.rs:1:39
   |
LL | fn no_elided_lt() -> impl Sized + use<'_> {}
   |                                       ^^ expected named lifetime parameter
   |
help: consider introducing a named lifetime parameter
   |
LL | fn no_elided_lt<'a>() -> impl Sized + use<'a> {}
   |                ++++                       ~~

Fix #134194.

r? @compiler-errors

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 3, 2025
@@ -3118,7 +3121,9 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
}
}

if num_params == 0 {
if in_precise_capture {
err.note("`use<...>` precise captures list require a named lifetime");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's not true. This works fine: fn foo(x: &u8) -> impl Sized + use<'_> {}.

@@ -4,33 +4,26 @@ error[E0106]: missing lifetime specifier
LL | fn no_elided_lt() -> impl Sized + use<'_> {}
| ^^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably at least keep some explanation that justifies why '_ isn't valid without another lifetime which it can resolve to in the inputs.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 3, 2025
@estebank estebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 3, 2025
);
if in_precise_capture {
err.note(
"this function's return type specifies a borrowed `use<'_>` with an elided \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"a borrowed use<'_>" feels really awkward. I think this can be a bit more direct. Perhaps something like:

"cannot capture elided lifetime with use<'_> when there is no lifetime in scope to capture"

@compiler-errors
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 23, 2025
@bors
Copy link
Collaborator

bors commented Feb 11, 2025

☔ The latest upstream changes (presumably #127541) made this pull request unmergeable. Please resolve the merge conflicts.

```
error[E0106]: missing lifetime specifier
  --> $DIR/bad-lifetimes.rs:1:39
   |
LL | fn no_elided_lt() -> impl Sized + use<'_> {}
   |                                       ^^ expected named lifetime parameter
   |
help: consider introducing a named lifetime parameter
   |
LL | fn no_elided_lt<'a>() -> impl Sized + use<'a> {}
   |                ++++                       ~~
```

Fix rust-lang#134194.
@bors
Copy link
Collaborator

bors commented Apr 17, 2025

☔ The latest upstream changes (presumably #139938) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid suggestion on anonymous lifetime parameter in precise capturing list if there are no input lifetimes
4 participants